import { useQuasar } from 'quasar'

export default function (cfg: cfg = {}) {
    const 组件id = cfg.组件id
    const $q = useQuasar()
    function 存列宽(列s: any[]) {
        const 字段集: any = $q.localStorage.getItem('字段集') || {}
        console.log(`字段集 👉`, 字段集)
        for (const item of 列s) {
            if (item.property) {
                // console.log(`item.property 👉`, item.property)
                // console.log(`item.width 👉`, item.width)
                let 字段id = 组件id + '.' + item.property
                字段集[字段id] = { 列宽: item.width }
            }
        }
        $q.localStorage.set('字段集', 字段集)
    }

    function 清空缓存() {
        $q.localStorage.clear()
    }

    function 取字段集() {
        const 字段集: any = $q.localStorage.getItem('字段集') || {}
        return 字段集
    }

    // const otherValue = $q.localStorage.getItem(key)
    return {
        取字段集,
        清空缓存,
        存列宽,
    }
}